<!-- XHTML 1.0 Strict -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<meta name="author" content="Rachid Touzani" />
<meta name="keywords" content=" css, dropdowns, dropdown menu, drop-down, menu, navigation, nav, horizontal, vertical left-to-right, vertical right-to-left, horizontal linear, horizontal upwards, cross browser, internet explorer, ie, firefox, safari, opera, browser, lwis" />
<meta name="description" content="Clean, standards-friendly, modular framework for dropdown menus" />
<link href="../css/dropdown.vertical.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../css/default.ultimate.css" media="screen" rel="stylesheet" type="text/css" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Solid and Structural Mechanics Demo 4</title>
<link rel="stylesheet" type="text/css" href="../doxygen.css" />
<link rel="stylesheet" type="text/css" href="../tabs.css"  />
</head>

<body bgcolor="#FFFFFF" link="#FF0000" vlink="#FF00FF" alink="#FF00FF">
<p align="center"><a href="../index.html"><img src="../im/ofeli.gif" width="150" border="0"></a></p>

<center>
  <div id="cse" style="width: 60%;">Loading</div>
  <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  <script type="text/javascript"> 
     google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY});
     google.setOnLoadCallback(function() {
        var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
        '012396140824982761142:-qrywxcfi_o', customSearchOptions);
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.draw('cse');
     }, true);
   </script>
   <style type="text/css">
     .gsc-control-cse {
     font-family: Verdana, sans-serif;
     border-color: #DAE0E5;
     background-color: #DAE0E5;
   }
   .gsc-control-cse .gsc-table-result { font-family: Verdana, sans-serif; }
   input.gsc-input { border-color: #B6BEC5; }
   input.gsc-search-button {
     border-color: #B6BEC5;
     background-color: #D0D1D4;
   }
   .gsc-tabHeader.gsc-tabhInactive {
     border-color: #999999;
     background-color: #EEEEEE;
   }
   .gsc-tabHeader.gsc-tabhActive {
     border-color: #999999;
     background-color: #999999;
   }
   .gsc-tabsArea { border-color: #999999; }
   .gsc-webResult.gsc-result,
   .gsc-results .gsc-imageResult {
     border-color: #FFFFFF;
     background-color: #FFFFFF;
   }
   .gsc-webResult.gsc-result:hover,
   .gsc-imageResult:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gsc-webResult.gsc-result.gsc-promotion:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gs-webResult.gs-result a.gs-title:link,
   .gs-webResult.gs-result a.gs-title:link b,
   .gs-imageResult a.gs-title:link,
   .gs-imageResult a.gs-title:link b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:visited,
   .gs-webResult.gs-result a.gs-title:visited b,
   .gs-imageResult a.gs-title:visited,
   .gs-imageResult a.gs-title:visited b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:hover,
   .gs-webResult.gs-result a.gs-title:hover b,
   .gs-imageResult a.gs-title:hover,
   .gs-imageResult a.gs-title:hover b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:active,
   .gs-webResult.gs-result a.gs-title:active b,
   .gs-imageResult a.gs-title:active,
   .gs-imageResult a.gs-title:active b { color: #0568CD; }
   .gsc-cursor-page { color: #0568CD; }
   a.gsc-trailing-more-results:link { color: #0568CD; }
   .gs-webResult .gs-snippet,
   .gs-imageResult .gs-snippet,
   .gs-fileFormatType { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl,
   .gs-imageResult div.gs-visibleUrl { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { display: none; }
   .gs-webResult div.gs-visibleUrl-long { display: block; }
   .gs-promotion div.gs-visibleUrl-short { display: none; }
   .gs-promotion div.gs-visibleUrl-long { display: block; }
   .gsc-cursor-box { border-color: #FFFFFF; }
   .gsc-results .gsc-cursor-box .gsc-cursor-page {
      border-color: #999999;
      background-color: #FFFFFF;
      color: #0568CD;
   }
   .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
      border-color: #999999;
      background-color: #999999;
      color: #0568CD;
   }
   .gsc-webResult.gsc-result.gsc-promotion {
      border-color: #D2D6DC;
      background-color: #D0D1D4;
   }
   .gsc-completion-title { color: #0568CD; }
   .gsc-completion-snippet { color: #5F6A73; }
   .gs-promotion a.gs-title:link,
   .gs-promotion a.gs-title:link *,
   .gs-promotion .gs-snippet a:link { color: #0066CC; }
   .gs-promotion a.gs-title:visited,
   .gs-promotion a.gs-title:visited *,
   .gs-promotion .gs-snippet a:visited { color: #0066CC; }
   .gs-promotion a.gs-title:hover,
   .gs-promotion a.gs-title:hover *,
   .gs-promotion .gs-snippet a:hover { color: #0066CC; }
   .gs-promotion a.gs-title:active,
   .gs-promotion a.gs-title:active *,
   .gs-promotion .gs-snippet a:active { color: #0066CC; }
   .gs-promotion .gs-snippet,
   .gs-promotion .gs-title .gs-promotion-title-right,
   .gs-promotion .gs-title .gs-promotion-title-right *  { color: #333333; }
   .gs-promotion .gs-visibleUrl,
   .gs-promotion .gs-visibleUrl-short { color: #5F6A73; }
   </style>
</center>
</p>
&nbsp;

<div id="mainmenu">
<div class="text">

 <div class="tabs">
   <ul class="tablist">
   <li><a href="../index.html"><span>Home</span></a>
   <li><a href="../overview.html"><span>Overview</span></a>
   <li><a href="../html/index.html"><span>Class Documentation</span></a>
   <li><a href="../fformats.html"><span>File Formats</span></a>
   <li><a href="../tutorial.html"><span>Tutorial</span></a>
   <li class="current"><a href="../demos.html"><span>Demo Codes</span></a>
 </div>

 </div>
 </div>

&nbsp;
<p>
<h2>Solid and Structural Mechanics Demo 4: A planar beam</h2>

<p><table border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="contact.html"><img src="../im/backward.gif" border="0"></a></td>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="truss.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>

<p>
<SPAN class=TEXT>
This code solves an elastic beam problem in structural mechanics theory. The libray <span class=LOGO>OFELI</span>
contains the class <span class=var><a href="../html/classOFELI_1_1Beam3DL2.html">Beam3DL2</a></span> that handles
elastic beams in the space with 6 degrees of freedom for each node. These degrees of freedom are supported
by the vertices of each element line.
</SPAN>

<ul type=square>
<li><SPAN class=TEXT>We start by defining an instance of class <span class=var>
<a href="../html/classOFELI_1_1IPF.html">IPF</a></span> to deal with project data.
We extract useful information from this instance: A verbosity and an output flag to deal with 
output levels. We next construct the 
<span class=var><a href="../html/classOFELI_1_1Mesh.html">Mesh</a></span> and the 
<span class=var><a href="../html/classOFELI_1_1Prescription.html">Prescription</a></span> instances.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   IPF data("beam - 1.0",argv[1]);
   int verbose = data.getVerbose();
   int output_flag = data.getOutput();
   Mesh ms(data.getMeshFile());
   Prescription p(ms,data.getDataFile());
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>
The linear system uses a symmetric matrix. For this, we
we use an instance of class <span class=var><a href="../html/classOFELI_1_1SkSMatrix.html">SkSMatrix&lt;double&gt;</a></span>.
Then we declare a vector that will contain the right-hand side and then
the solution. Next, we read boundary conditions and prescribed concentrated loads
from the prescription file. These are stored in vectors <span class=TT>bc</span>
and <span class=TT>bf</span> respectively:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   SkSMatrix&lt;double&gt; A(ms);
   Vect&lt;double&gt; b(ms), bc(ms), bf(ms);
   p.get(BOUNDARY_CONDITION,bc,0);
   p.get(POINT_FORCE,bf);
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>The global matrix and right-hand side are, as usual, filled
by looping over elements. For each element, an instance of class 
<span class=var><a href="../html/classOFELI_1_1Beam3DL2.html">Beam3DL2</a></span>
is considered. This class deals with quadrilateral elements. The member function
<span class=TT>Stiffness</span> adds the contribution of the element stiffness
matrix. 
The other member functions have already been considered in previous lessons.
Note that the load vector is a copy of the concentrated load vector. No need for
assembly here.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   MeshElements(ms) {
      Beam3DL2 eq(theElement,0.1,0.1,0.1);
      eq.Stiffness();
      eq.ElementAssembly(A);
      eq.ElementAssembly(b);
   }
   b = bf;
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>We can now prescribe boundary conditions by penalty method
and solve the resulting linear system by factorization and backsubstitution.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   A.Prescribe(b,bc);
   A.solve(b);
</font></pre>
</td></tr></table>
</SPAN></p>

<li type=square><SPAN class=TEXT>Let us now extract some additional information from
the class. We want to output, for each element, the axial force, the bending moment, the
twisting moment and the shear force. This is done simply by invoking corresponding member
functions in the class <span class=var><a href="../html/classOFELI_1_1Beam3DL2.html">Beam3DL2</a></span>.
Note that we need, before that, to construct the vector of node displacements. A dedicated
constructor is made for that. Then we recall the member functions we need for post-processing.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; u(ms,3);
   Beam3DL2 eq(ms,uf,u);
   cout &lt;&lt; "Element     Axial Force       Bending Moment    Twisting Moment   Shear Force" &lt;&lt; endl;
   MeshElements(ms) {
      Beam3DL2 eq(theElement,0.1,0.1,0.1,b);
      cout &lt;&lt; setw(8) &lt;&lt; theElementLabel;
      cout &lt;&lt; " " &lt;&lt; eq.AxialForce();
      cout &lt;&lt; " " &lt;&lt; eq.BendingMoment();
      cout &lt;&lt; " " &lt;&lt; eq.TwistingMoment();
      cout &lt;&lt; " " &lt;&lt; eq.ShearForce() &lt;&lt; endl;
   }
</font></pre>
</td></tr></table>
</SPAN></p>

<li type=square><SPAN class=TEXT>We finally show here how to create a deformed mesh
for a graphical presentation. We have for this the function 
<span class=TT><a href="../html/group__Mesh.html#g2d92b1248fa3264a3509f90872e0ec29">DeformMesh</a></span>
that modifies node coordinates by adding the displacement vector to the coordinates.
The function can also multiply the displacement by an amplification factor which is equal 
here to <span class=TT>1</span> by default. Then we store the resulting mesh into a new file.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   DeformMesh(ms,u);
   ms.put("deformed_beam.m");
</font></pre>
</td></tr></table>
</SPAN>
</ul></p>

&nbsp;&nbsp;
<h2>An example</h2>

<SPAN class=TEXT>
Let us run this program with an example of a straight bar <span class=TT>[0,1]</span>.
We define the project file:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
&lt;OFELI_File&gt;
&lt;info&gt;
   &lt;title /&gt;
   &lt;date /&gt;
   &lt;author /&gt;
&lt;/info&gt;

&lt;Project name="beam"&gt;
   &lt;mesh_file value="beam.dat"/&gt;
   &lt;data_file value="beam.dat" /&gt;
   &lt;verbose value="1" /&gt;
   &lt;output value="0"&gt;
   &lt;save value="1"/&gt;
   &lt;plot value="1"/&gt;
   &lt;init value="1"/&gt;
   &lt;plot_file value="beam.d"/&gt;
&lt;/Project&gt;

&lt;Mesh dim="3" nb_dof="6"&gt;
   &lt;Nodes&gt;
      0.00000000e+00      0.00000000e+00      0.00000000e+00   111111
      1.25000000e-01      0.00000000e+00      0.00000000e+00        0
      2.50000000e-01      0.00000000e+00      0.00000000e+00        0
      3.75000000e-01      0.00000000e+00      0.00000000e+00        0
      5.00000000e-01      0.00000000e+00      0.00000000e+00        0
      6.25000000e-01      0.00000000e+00      0.00000000e+00        0
      7.50000000e-01      0.00000000e+00      0.00000000e+00        0
      8.75000000e-01      0.00000000e+00      0.00000000e+00        0
      1.00000000e+00      0.00000000e+00      0.00000000e+00        0
   &lt;/Nodes&gt;
   &lt;Elements shape="line"  nodes="2"&gt;
       1       2       1          2       3       1          
       3       4       1          4       5       1          
       5       6       1          6       7       1
       7       8       1          8       9       1   
   &lt;/Elements&gt;
&lt;/Mesh&gt;
&lt;Prescription&gt;
   &lt;PointForce x="1" dof="2"&gt;-0.01&lt;/PointForce&gt;
   &lt;PointForce x="1" dof="3"&gt; 0.01&lt;/PointForce&gt;
&lt;/Prescription&gt;
&lt;/OFELI_File&gt;</font></pre>
</td></tr></table></p>

<p>
Let us give some explanations about this project file:
<ul>
<li>The project file contains all data necessary for the code: General problem parameters,
mesh data and prescriptions.
<li>The finite element mesh consists in 8 beam elements, where the first node (<span class=TT>x=0</span>)
has all its degrees of freedom constrained.
<li>We impose a load concentrated at the end point (<span class=TT>x=1</span>): The degrees
of freedom 2 and 3 are loaded. Note that since we don't prescribe any boundary condition, then
by default, the first end (<span class=TT>x=0</span>) is fixed.
</ul>
</span>

<p><table align="center" border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="contact.html"><img src="../im/backward.gif" border="0"></a></td>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="truss.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>

&nbsp;
<div id="foot_bar">
        Copyright &copy; 1998-2018 Rachid Touzani&nbsp;
</div>

</body>
</html>
